package com.cindata

class AccountCity
{
    Account account
    City city

    Date createdDate = new Date()
    Date modifiedDate = new Date()
    User createBy
    User modifyBy

    static constraints = {
        createdDate nullable: true, blank: true
        modifiedDate nullable: true, blank: true
        createBy nullable: true, blank: true
        modifyBy nullable: true, blank: true

        account nullable: true, blank: true
        city nullable: true, blank: true
    }
    static mapping = {
        sort 'city.name'
    }
    def springSecurityService

    def beforeInsert()
    {
        def username = springSecurityService?.getPrincipal()?.username
        createBy = User.findByUsername(username)
    }

    def beforeUpdate()
    {
        modifiedDate = new Date()
        def username = springSecurityService?.getPrincipal()?.username
        modifyBy = User.findByUsername(username)
    }
}
